package com.mzq.langchain4j_springboot.web.service.Impl;


import com.mzq.langchain4j_springboot.web.entity.SysUser;
import com.mzq.langchain4j_springboot.web.mapper.SysUserMapper;
import com.mzq.langchain4j_springboot.web.service.ISysUserService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.ToolSpecification.*;
import dev.langchain4j.agent.tool.Tool;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 用户 业务层处理
 *
 * @author ruoyi
 */
@Service
public class SysUserServiceImpl implements ISysUserService
{
    private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);

    @Resource
    private SysUserMapper userMapper;

    @Override
    public List<SysUser> selectUserList(SysUser user)
    {
        return userMapper.selectUserList(user);
    }

    @Override
    public int insertUser(SysUser user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int updateUser(SysUser user) {
        return userMapper.updateUser(user);
    }

//    //告诉ai 什么对话才调用这个方法
//    @Tool("长沙有多少个叫名字的")
//    public Integer changshaNameCount(
//            //告诉ai需要提取的信息
//            @P("姓名")String name){
//        System.out.println("name=========>"+name);
//        return 10;
//    }
//
//    //退票
//    @Tool("退票")
//    public String cancelBooking(
//            //告诉ai需要提取的信息
//            @P("预订号")String bookingNumber,
//            @P("姓名")String name){
//        //todo 调用业务方法 数据库操作
//        System.out.println("name=========>"+name);
//        System.out.println("bookingNumber=========>"+bookingNumber);
//        return "退票成功";
//    }

    //查询房产信息列表
    @Tool("输入问题：土地房产管理人某公司关联多少房产，展示具体信息")
    public List<Map<String, String>> selectRealEstateInformation(
            //告诉ai需要提取的信息
            @P("公司名")String name){
        System.out.println("name=========>"+name);
        List<Map<String, String>> maps = userMapper.selectRealEstateInformation(name);
        System.out.println("maps=========>"+maps);
//        System.out.println("maps=========>"+maps);  userMapper.selectRealEstateInformation(name).toString()
        return maps;
    }
}
